import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vite.dev/config/
export default defineConfig({
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/styles/element/index.scss" as *;`,
      }
    },
  },
  plugins: [
    vue(),
    AutoImport({
      // targets to transform
      include: [
        /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
        /\.vue$/,
        /\.vue\?vue/, // .vue
        /\.md$/, // .md
      ],
      // 自动导入 Vue 组合式 API 函数
      imports: ['vue', 'vue-router'],
      // Generate corresponding .d.ts file.
      // 生成对应的 .d.ts 声明文件
      dts: 'src/auto-imports.d.ts',
      resolvers: [
        ElementPlusResolver({
          importStyle: "sass",
        })
      ]
    }),
    Components({
      resolvers: [
        ElementPlusResolver({
          importStyle: "sass",
        })
      ]
    }),
  ], 
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  }
})
